<?php

namespace app\controller\v1;

// 这个类 专门作用于获取一些 公共的配置  例如 查询部门列表  分类列表 规避前端的权限设计
use app\model\LineModel;
use app\model\VendorsModel;
use think\response\Json;

class Common extends System
{

    /**
     * Notes: 生产线列表
     * User: chenLei
     * 10/20/25 09:55:26
     * @return Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function lineList(): Json
    {
        $list = LineModel::field('id,name,status')->where('status', LineModel::STATUS_ENABLED)
            ->select()->toArray();

        return $this->successJson('ok', $list);
    }


    /**
     * Notes: 外协列表
     * User: chenLei
     * 10/20/25 10:00:06
     * @return Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function vendorsList(): Json
    {
        $list = VendorsModel::field('id,name,status')->where('status', VendorsModel::STATUS_ENABLED)
            ->where('company_id', $this->params['company_id'])
            ->select()->toArray();
        return $this->successJson('ok', $list);
    }


}